
using Microsoft.EntityFrameworkCore;
using NLog.Web;
using SY.BasicData.Infrastructures;
using System.Reflection;
using ServiceManagement.Consul;
namespace SY.BasicData.Api.Write
{
    /// <summary>
    /// ������
    /// </summary>
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);
            builder.Configuration.Register();
            //builder.Configuration.Register();
            //ע��
            builder.Services.AddDbContext<DBDbContext>(x => { x.UseSqlServer(builder.Configuration.GetConnectionString("Conn")); });
            // Add services to the container.
            //��־
            builder.Host.UseNLog();
            //�н���
            builder.Services.AddMediatR(x => { x.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()); });
            //ע��AutoMapper
            builder.Services.AddAutoMapper(typeof(MapperProFiles));
            //ע��ִ�
            builder.Services.AddScoped(typeof(IBaseRepository<>), typeof(BaseRepository<>));
            builder.Services.AddControllers();
            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            builder.Services.AddEndpointsApiExplorer();
            builder.Services.AddSwaggerGen(async x => {

                var file = Path.Combine(AppContext.BaseDirectory + "SY.BasicData.Api.Write.xml");
                x.IncludeXmlComments(file, true);
            
            });

            var app = builder.Build();

            // Configure the HTTP request pipeline.
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI();
            }
            //����
            app.UseCors(x => x.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
            //��̬�ļ�
            app.UseStaticFiles();
            app.UseAuthorization();


            app.MapControllers();

            app.Run();
        }
    }
}
